package com.qf.servleProject.service.impl;

import com.qf.servleProject.dao.ManagerDAO;
import com.qf.servleProject.dao.impl.ManagerDaoImpl;
import com.qf.servleProject.entity.Admin;
import com.qf.servleProject.entity.Manager;
import com.qf.servleProject.service.ManagerService;
import com.qf.servleProject.utils.DbUtils;

public class ManagerServiceImpl implements ManagerService {
    private ManagerDAO managerDAO = new ManagerDaoImpl();

    @Override
    public Manager login(String username, String password) {
        Manager manager = null;
        try {
            DbUtils.begin();
            Manager temp = managerDAO.select(username);
            if (temp!=null) {
                if (temp.getPassword().equals(password)) {
                    manager = temp;
                }
            }
            DbUtils.commit();
        } catch (Exception e) {
            DbUtils.rollback();
            e.printStackTrace();
        }
        return manager;
    }

}
